#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define pb push_back
#define mp make_pair
#define pii pair <int, int>
#define fast_io ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define F first
#define S second
const int N = 1e5 + 5;
vector<int> adj[N];
int d[N];
int dp[N];
int main(){
fast_io;
int n, m;
cin >> n >> m;
int a, b;
for(int i = 0; i < m; i++)
{
cin >> a >> b;
d[a]++; d[b]++;
if(a < b) swap(a, b);
adj[a].pb(b);
}
for(int i = 1; i <= n; i++)
{
if(adj[i].size() == 0) dp[i] = 1;
else
{
for(int u : adj[i])
{
dp[i] = max(dp[i], dp[u] + 1);
}
}
}
ll ans = 0;
for(int i = 1; i <= n; i++)
{
ans = max(ans, 1LL * dp[i] * d[i]);
}
cout << ans;
return 0;
}
e-maze-in | Bricks Game |
Char Sum | Two Strings |
Anagrams | Prime Number |
Lexical Sorting Reloaded | 1514A - Perfectly Imperfect Array |
580A- Kefa and First Steps | 1472B- Fair Division |
996A - Hit the Lottery | MSNSADM1 Football |
MATCHES Playing with Matches | HRDSEQ Hard Sequence |
DRCHEF Doctor Chef | 559. Maximum Depth of N-ary Tree |
821. Shortest Distance to a Character | 1441. Build an Array With Stack Operations |
1356. Sort Integers by The Number of 1 Bits | 922. Sort Array By Parity II |
344. Reverse String | 1047. Remove All Adjacent Duplicates In String |
977. Squares of a Sorted Array | 852. Peak Index in a Mountain Array |
461. Hamming Distance | 1748. Sum of Unique Elements |
897. Increasing Order Search Tree | 905. Sort Array By Parity |
1351. Count Negative Numbers in a Sorted Matrix | 617. Merge Two Binary Trees |